﻿using System.Web.Http;
using Yks.Notify.Client.ApiModels;
using Yks.Notify.Client.Services;

namespace Yks.Notify.Client.Controller
{
    public class TfsReceiverController : ApiController
    {
        private readonly INotifyShower _notifyShower;

        public TfsReceiverController(INotifyShower notifyShower)
        {
            _notifyShower = notifyShower;
        }

        [Route("api/TfsReceiver/" + nameof(PullRequestCreated))]
        public void PullRequestCreated([FromBody] TfsPullRequestCreatedMessage body)
        {
            _notifyShower.ShowNotify(body.id, body.message.text, body.detailedMessage.text);
        }

        [Route("api/TfsReceiver/" + nameof(BuildCompleted))]
        public void BuildCompleted([FromBody] TfsBuildCompletedMessage body)
        {
            _notifyShower.ShowNotify(body.id, body.message.text, body.detailedMessage.text);
        }

        [Route("api/TfsReceiver/" + nameof(PullRequestUpdated))]
        public void PullRequestUpdated([FromBody] TfsPullRequestUpdatedMessage body)
        {
            _notifyShower.ShowNotify(body.id, body.message.text, body.detailedMessage.text);
        }
    }
}